using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace MCromwell.StaffIntranet.UI
{
    public class ExceptionCatcherModule : IHttpModule
    {
        const string ERROR_PAGE = "~/ErrorOccured.aspx";

        public void Init(HttpApplication context)
        {
            context.Error += new EventHandler(HandleError);
        }

        void HandleError(object sender, EventArgs e)
        {

            HttpApplication application = (HttpApplication)sender;
            if (application.Request.Url.AbsoluteUri.LastIndexOf(ERROR_PAGE) == -1)
            {
                application.Server.Transfer(ERROR_PAGE, true);
            }
        }

        public void Dispose()
        {
            
        }

        
    }
}
